package com.yunyan.util.predict;

import java.util.ArrayList;
import java.util.List;

public class SmoothCheck {

    public static boolean check (int[] X0){
        double[] X1 = new double[X0.length]; // 累计求和数组
        // 累计求和
        X1[0] = X0[0];
        for (int i = 1; i < X0.length; i++) {
            X1[i] = X1[i - 1] + X0[i];
        }

        List<Double> rho = new ArrayList<>(); // rho值
        for (int i = 1; i < X1.length; i++) {
            rho.add(X0[i] / X1[i - 1]);
        }

        List<Double> rhoRatio = new ArrayList<>(); // rho比值
        for (int i = 0; i < rho.size() - 1; i++) {
            rhoRatio.add(rho.get(i + 1) / rho.get(i));
        }

        System.out.println("rho: " + rho);
        System.out.println("rho_ratio: " + rhoRatio);

        boolean flag = true;
        for (int i = 0; i < rho.size() - 1; i++) {
            if (rho.get(i) > 0.5 || rho.get(i + 1) / rho.get(i) >= 1) {
                flag = false;
                break;
            }
        }

        if (rho.get(rho.size() - 1) > 0.5) {
            flag = false;
        }

        if (flag) {
        } else {
        }
        return flag;
    }

    public static void main(String[] args) {
        int[] X0 = new int[]{680, 670, 655}; // 初始数据
        check(X0);
    }
}
